package com.xiaolin.hrsystem.controller;

import com.xiaolin.hrsystem.service.SSOService;
import com.xiaolin.hrsystem.utils.OptResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author xiaolin
 * @description 描述
 * @since 2024/10/9
 */
@RestController
@RequestMapping("/userSsoAth")
public class SSOController {
    @Autowired
    private SSOService ssoService;

    /**
     * 根据code登录
     * @param code
     * @param response
     * @return
     */
    @PostMapping("/login/{code}")
    public OptResult login(@PathVariable String code, HttpServletResponse response) {
        return ssoService.login(code, response);
    }

    /**
     * 获取用户信息
     *
     * @return
     */
    @PostMapping("/info")
    public OptResult info(HttpServletRequest request) {
        return ssoService.info(request);
    }

    /**
     * 用户注销
     *
     * @return
     */
    @PostMapping("/logout")
    public OptResult logout(HttpServletRequest request) {
        return ssoService.logout(request);
    }

    /**
     * 用户注销回调接口
     *
     * @return
     */
    @PostMapping("/logoutCallback/{token}")
    public OptResult logoutCallback(@PathVariable String token) {
        return ssoService.logoutCallback(token);
    }
}
